package com.mrslu.signkk.pojo.identity;

import com.aliyun.core.utils.StringUtils;
import com.mrslu.signkk.exception.ServiceException;

public enum UserRoleEnum {

    /**
     * 参与者
     */
    PARTNER,

    /**
     * 管理员
     */
    MANAGER;


    public static boolean isPartner(UserRoleEnum userRole) {
        return PARTNER.equals(userRole);
    }


    public static boolean isManager(UserRoleEnum userRole) {
        return MANAGER.equals(userRole);
    }


    public static UserRoleEnum parseUserRole(String userRoleValue) {
        if (StringUtils.isBlank(userRoleValue)) {
            return null;
        }
        try {
            return UserRoleEnum.valueOf(userRoleValue);
        } catch (Exception e) {
            throw new ServiceException("无效的参数：" + userRoleValue);
        }
    }


}
